import { post, get } from "utils/fetch";

// 查询租户
export const getTenantList = ({ searchName, pageNum, pageSize }) => {
  return post(`/flow-platform/tenant/list`, {
    searchName,
    pageNum,
    pageSize,
  });
};

// 新增租户
export const addTenant = ({
  tenantName,
  tenantCode,
  description,
  contactName,
  contactPhone,
}) => {
  return post(
    `/flow-platform/tenant/add`,
    {
      tenantName,
      tenantCode,
      description,
      contactName,
      contactPhone,
    },
    { messageType: "close" },
  );
};

// 编辑租户
export const editTenant = ({
  tenantName,
  tenantCode,
  id,
  description,
  contactName,
  contactPhone,
}) => {
  return post(
    `/flow-platform/tenant/edit`,
    {
      tenantName,
      tenantCode,
      id,
      description,
      contactName,
      contactPhone,
    },
    { messageType: "close" },
  );
};

// 删除租户
export const delTenant = ({ tenantId }) => {
  return post(
    `/flow-platform/tenant/delete`,
    {
      tenantId,
    },
    { messageType: "close" },
  );
};

//
export const listUsers = ({ tenantId }) => {
  return get(
    `/flow-platform/tenant/listUsers/${tenantId}`,
    {},
    { messageType: "close" },
  );
};

// 租户增加 / 删除用户
export const submitUsers = (data) => {
  return post(`/flow-platform/tenant/submitUsers`, data, {
    messageType: "close",
  });
};

// 查看租户详情
export const queryTenant = ({ tenantId }) => {
  return get(
    `/flow-platform/tenant/${tenantId}`,
    null,
    { messageType: "close" },
  );
};

// 校验用户是否已授权应用
export const getAuthorizedApp = (data) => {
  return post(`/flow-platform/tenant/getAuthorizedApp`, data, {
    messageType: "close",
  });
};
